<%
  #File:    /app/views/manage/permissions/_editor_group_form.rhtml
  #Author:  Andrew Stone
  #Created: 05.22.2006
  title = "Creating editor group"
  title = "Updating editor group id: #{@editor_group.id}" if @editor_group.id
  action = "create_editor_group"
  action = "update_editor_group" if @editor_group.id
%>
  
<%=error_messages_for("editor_group")%>

<%=start_form_tag(:action => action)%>
<%=start_large_div_wrapper%>
  <div id="page_title"><%=title%></div>
  <div id="large">
    <p>
    User checked will have <strong>update access</strong> to to update pages or managed documents.
    </p>
    <br/>
    <fieldset>
      <label class="required" for="editor_group_name">* Name: <%=text_field("editor_group","name")%></label>
      <%=tabs(["Users","Folders","Pages","Document Categories"])%>
      <%#
        #Users
      -%>
      <div id="content_users" class="tab_content">
        <ul class="object_checklist">
        <% 
          i = 0;
          @users.each do |usr| 
            bg = row_class(i)
            i += 1
            checked = ""
            checked = "checked" if @editor_group.has_user_id?(usr.id)
            bg << "_" << checked if checked.length > 0
            gid = "group_user_#{usr.id}" %>
            <li class="<%=bg%>">
              <label for="<%=gid%>">
                <input id="<%=gid%>" name="<%=gid%>" type="checkbox" <%=checked%>/><%=h(usr.full_name_with_login)%>
              </label>
            </li>
        <%
          end %>
        </ul>
      </div>
      <%#
        #Folders
      -%>
      <div id="content_folders" class="tab_content" style="display:none">
        <ul class="object_checklist">
        <% 
          i = 0;
          @folders.each do |fldr| 
            bg = row_class(i)
            i += 1
            checked = ""
            checked = "checked" if @editor_group.has_folder_id?(fldr[:id])
            bg << "_" << checked if checked.length > 0
            gid = "folder_#{fldr[:id]}" %>
            <li class="<%=bg%>">
              <label for="<%=gid%>">
                <input id="<%=gid%>" name="<%=gid%>" type="checkbox" <%=checked%>/><%=h(fldr[:name])%>
              </label>
            </li>
        <%
          end %>
        </ul>
      </div>
      <%#
        #Pages
      -%>
      <div id="content_pages" class="tab_content" style="display:none">
        <ul class="object_checklist">
        <% 
          i = 0;
          @pages.each do |pg| 
            bg = row_class(i)
            i += 1
            checked = ""
            checked = "checked" if @editor_group.has_page_id?(pg[:id])
            bg << "_" << checked if checked.length > 0
            gid = "page_#{pg[:id]}" %>
            <li class="<%=bg%>">
              <label for="<%=gid%>">
                <input id="<%=gid%>" name="<%=gid%>" type="checkbox" <%=checked%>/><%=h(pg[:name])%>
              </label>
            </li>
        <%
          end %>
        </ul>
      </div>
      <%#
        #Document Categories
      -%>
      <div id="content_document_categories" class="tab_content" style="display:none">
        <ul class="object_checklist">
        <% 
          i = 0;
          @document_categories.each do |dc| 
            bg = row_class(i)
            i += 1
            checked = ""
            checked = "checked" if @editor_group.has_document_category_id?(dc.id)
            bg << "_" << checked if checked.length > 0
            gid = "document_category_#{dc.id}" %>
            <li class="<%=bg%>">
              <label for="<%=gid%>">
                <input id="<%=gid%>" name="<%=gid%>" type="checkbox" <%=checked%>/><%=h(dc.name)%>
              </label>
            </li>
        <%
          end %>
        </ul>
      </div>
    </fieldset>
    <%=hidden_field("editor_group","id")%>
    <div id="actions">
      <%=submit_tag("Cancel")%>
      <%=submit_tag(action.gsub(/_/," ").capitalize)%>
    </div>
  </div>
<%=end_div_wrapper%>
<%=end_form_tag%>
